
public class AVLNode {
		AVLNode lChild, rChild, parent;
		int key;
		Object data;
		int height;
		
		public AVLNode( int newKey, Object newData)
		{
			key = newKey;
			data = newData;
			lChild = null;
			rChild = null;
			parent = null;
			height = 0;
		}
		
		public AVLNode( int newKey, Object newData, AVLNode p )
		{
			key = newKey;
			data = newData;
			lChild = null;
			rChild = null;
			parent = p;
			height = 0;
		}
		
		public void setHeight()
		{
			int lHeight = -1, rHeight = -1;
			if( lChild != null )
				lHeight = lChild.height;
			if( rChild != null )
				rHeight = rChild.height;
			height = Math.max( lHeight, rHeight ) + 1;
		}
		
		public void copy(AVLNode n)
		{
			key = n.key;
			data = n.data;
		}

		
		public int Search(int id,int CheckCounter) {
			CheckCounter++;		// a new check
			if(key==id)
				return CheckCounter;		//return true - a positive number
			else
			{
				if(key>id && lChild!=null)
				{
					return lChild.Search(id,CheckCounter);
				}
				else if(key<id && rChild!=null)
					return rChild.Search(id,CheckCounter);
					else		// the id was not found - the son in the correct direction was null 
					{
						CheckCounter=CheckCounter+1;		// add the null son check
						CheckCounter=-CheckCounter; 		// return false - a negetive number
						return CheckCounter;
					}			
			}
		}


}
